const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('Likes', {
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: false,
      primaryKey: true
    },
    postid: {
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: true,
      references: {
        model: 'Articles', // 关联的模型名称
        key: 'id' // 关联的字段名称
      },
      comment: "对应文章id"
    },
    userid: {
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: true,
      references: {
        model: 'Users', // 关联的模型名称
        key: 'id' // 关联的字段名称
      },
      comment: "对应用户id"
    },

  }, {
    sequelize,
    tableName: 'Likes',
    timestamps: true,
  });
};
